<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

function debounce(
  callback: (...args: any[]) => void,
  delay: number
): (...args: any[]) => void {
  let tid: any;

  return function (...args: any[]) {
    // @ts-ignore
    // eslint-disable-next-line @typescript-eslint/no-this-alias
    const ctx = this;
    if (tid) {
      clearTimeout(tid);
    }
    tid = setTimeout(() => {
      callback.apply(ctx, args);
    }, delay);
  };
}

const originalResizeObserver = (window as any).ResizeObserver;
(window as any).ResizeObserver = class ResizeObserver extends (
  originalResizeObserver
) {
  constructor(callback: (...args: any[]) => void) {
    callback = debounce(callback, 100); // 尝试将延迟时间增加到 100 毫秒
    super(callback);
  }
};

export default defineComponent({
  setup() {
    // 这里可以添加任何需要在组件创建时执行的逻辑
  },
});
</script>
